//
//  CompareDate.m
//  BuffetNews
//
//  Created by 大大大鸿哥 on 14/11/5.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "CompareDate.h"

@implementation CompareDate
+(NSString *) compareCurrentTime:(NSDate*) compareDate
{
        NSTimeInterval  timeInterval = [compareDate timeIntervalSinceNow];
        timeInterval = -timeInterval;
        long temp = 0;
        if (timeInterval < 60) {
        NSString *result = [NSString stringWithFormat:@"刚刚"];
            return  result;

        }
        else if((temp = timeInterval/60) <60){
        NSString *result = [NSString stringWithFormat:@"%ld分钟前",temp];
            return  result;

        }
        
        else if((temp = temp/60) <24){
        NSString *result = [NSString stringWithFormat:@"%ld小时前",temp];
            return  result;

        }
        
        else if((temp = temp/24) <30){
        NSString *result = [NSString stringWithFormat:@"%ld天前",temp];
            return  result;

        }
        
        else if((temp = temp/30) <12){
        NSString *result = [NSString stringWithFormat:@"%ld个月前",temp];
            return  result;

        }
        else{
            temp = temp/12;
        NSString *result = [NSString stringWithFormat:@"%ld年前",temp];
            return  result;

        }

}
@end
